/*    */ package com.zimbra.cs.account.ldap;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.SearchDirectoryOptions.ObjectType;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import com.zimbra.cs.ldap.ZLdapFilter;
/*    */ import com.zimbra.cs.ldap.ZSearchControls;
/*    */ import com.zimbra.cs.ldap.ZSearchResultEntry;
/*    */ import com.zimbra.cs.ldap.ZSearchResultEnumeration;
/*    */ import com.zimbra.cs.ldap.ZSearchScope;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BySearchResultEntrySearcher
/*    */ {
/*    */   private final LdapProvisioning prov;
/*    */   private final Domain domain;
/*    */   private final SearchEntryProcessor visitor;
/*    */   private final String[] returnAttrs;
/*    */   private final ZLdapContext zlc;
/*    */   
/*    */   public BySearchResultEntrySearcher(LdapProvisioning prov, ZLdapContext zlc, Domain domain, String[] retAttrs, SearchEntryProcessor visitor)
/*    */   {
/* 46 */     this.prov = prov;
/* 47 */     this.zlc = zlc;
/* 48 */     this.domain = domain;
/* 49 */     this.returnAttrs = retAttrs;
/* 50 */     this.visitor = visitor;
/*    */   }
/*    */   
/*    */   public void doSearch(ZLdapFilter filter, Set<SearchDirectoryOptions.ObjectType> types) throws ServiceException {
/* 54 */     String[] bases = this.prov.getSearchBases(this.domain, types);
/* 55 */     for (String base : bases) {
/*    */       try {
/* 57 */         ZSearchControls ctrl = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, 0, this.returnAttrs);
/*    */         
/* 59 */         ZSearchResultEnumeration results = this.prov.getHelper().searchDir(base, filter, ctrl, this.zlc, LdapServerType.REPLICA);
/*    */         
/* 61 */         while (results.hasMore()) {
/* 62 */           ZSearchResultEntry sr = results.next();
/* 63 */           this.visitor.processSearchEntry(sr);
/*    */         }
/* 65 */         results.close();
/*    */       } catch (ServiceException e) {
/* 67 */         ZimbraLog.search.debug("Unexpected exception whilst searching", e);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public static abstract interface SearchEntryProcessor
/*    */   {
/*    */     public abstract void processSearchEntry(ZSearchResultEntry paramZSearchResultEntry);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/BySearchResultEntrySearcher.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */